package com.example.lay.intent;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;


public class MyIntent extends Activity {

    private final static String ACTION = "cl.intent.action.SECOND";
    private final static String CATEGORY = "cl.intent.category.SECOND";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_intent);
        ((TextView) findViewById(R.id.textView)).setText(getIntent().getAction());
        ((Button) findViewById(R.id.button)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                ComponentName compoent = new ComponentName(MyIntent.this,SecondActivity.class);
//                Intent intent = new Intent();
//                intent.setComponent(compoent);
//                startActivity(intent);
                //
//                Intent intent = new Intent();
//                intent.setAction(MyIntent.ACTION);
//                intent.addCategory(MyIntent.CATEGORY);
//                startActivity(intent);
//                startActivity(new Intent(MyIntent.this,ContactsActivity.class));
                /*返回桌面
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_MAIN);
                intent.addCategory(Intent.CATEGORY_HOME);
                startActivity(intent);
                */
                /*DataAndType
                startActivity(new Intent(MyIntent.this,DataAndTypeAcvitity.class));
                */
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                intent.setData(Uri.parse("content://com.android.contacts/contacts/1"));
                startActivity(intent);
            }
        });
    }
}
